<?php

require_once dirname(__FILE__).'/../lib/projectGeneratorConfiguration.class.php';
require_once dirname(__FILE__).'/../lib/projectGeneratorHelper.class.php';

/**
 * project actions.
 *
 * @package    help
 * @subpackage project
 * @author     Evgeny Babin <psylosss@gmail.com>
 * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class projectActions extends autoProjectActions
{
  function executeChange(sfWebRequest $request)
  {
    $project=Doctrine::getTable('Project')->find($request->getParameter('id'));
    
    $this->forward404Unless($project, sprintf('Проект не найден (%s).', $request->getParameter('id')));
    
    $this->forward404Unless($project->isVisibleToUser($this->getUser()->getGuardUser()->Profile), 'Нет доступа к этому проекту.');
    
    //Сохраняем в БД текущий проект
    $user=$this->getUser()->getGuardUser();
    $user->Profile->CurrentProject=$project;
    $user->Profile->save();
    
    $this->redirect('@homepage');
  } 
  
  function executeNoProjects(sfWebRequest $request)
  {
  
  }
  
  function executeChooseProject(sfWebRequest $request)
  {
    $this->projects=$this->getUser()->getGuardUser()->Profile->Projects;
  }
  
  
}
